<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>buffer size restriction functionality of resource timing</title>
        <script>
            var buffer_size = 2;
            var supportBufferControlInterface = false;
            if (performance && performance.setResourceTimingBufferSize)
            {
                supportBufferControlInterface = true;
                performance.setResourceTimingBufferSize(buffer_size);
            }

        </script>
        <link rel="author" title="Intel" href="http://www.intel.com/" />
        <link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
        <script src="/webperf/tests/resources/webperftestharness.js"></script>
        <script>
            setup({ explicit_done: true });            
            test_namespace();
            if (performance && performance.clearResourceTimings) {
                performance.clearResourceTimings();
                for (var i = 1; i <= 3; i++) {
                    var image = document.createElement("img");
                    image.src = "/webperf/tests/resources/generate_resource.php?type=image&id=" + i;
                }
            }

            function onload_test()
            {
                if (!supportBufferControlInterface || !performance.getEntriesByType)
                    test_true(false, "Resource Timing and Performance Timeline interface required by this test are supported!");
                else
                    test_equals(performance.getEntriesByType("resource").length, buffer_size, buffer_size + " resource timing entries should be stored since buffer size is " + buffer_size + "!");
                done();                
            }
        </script>
    </head>
    <body onload="onload_test();">
        <h1>Description</h1>
        <p>This test validates the functionality of setResourceTimingBufferSize method in resource timing.</p>
        <div id="log"></div>
    </body>
</html>
